'use strict';

const { WorkloadModuleBase } = require('@hyperledger/caliper-core');


const xs = ['0-0-0','0-0-1','0-1-1','1-1-1','1-1-2','1-2-2','2-2-2'];
const ys = ['000','001','011','111','112','122','222'];



class CreateMatrixWorkload extends WorkloadModuleBase {
    constructor() {
        super();
        this.txIndex = 0;
    }



    async submitTransaction() {
        this.txIndex++;
        let matrixNumber = 'client' + this.workerIndex + '_Matrix' + this.txIndex.toString();
        let x = xs[Math.floor(Math.random()*xs.length)];
        let y = ys[Math.floor(Math.random()*ys.length)];
        const Args = {
            contractId: 'credit-evaluation',
            contractVersion: 'v1.0',
            contractFunction: 'CreateMatrix',
            invokerIdentity: 'Admin',
            contractArguments: [matrixNumber, x, y],
            timeout: 30
        };

        await this.sutAdapter.sendRequests(Args);
    }

 
}

function createWorkloadModule() {
    return new CreateMatrixWorkload();
}

module.exports.createWorkloadModule = createWorkloadModule;